-- curse
-- create by panyl
-- 诅咒，不用触发，计算攻击时apply就行

return {
    apply = function(prop, baseValue)
        -- 提升的值
        return baseValue - math.modf(baseValue * prop[3] / 1000);
    end,

    -- 每回合触发
    trigger = function(who, prop, base)
        local reduce = prop[3];

        -- 诅咒抗性
        local p = PropM.combine(who, "curse_resist", 1);
        reduce = PropM.apply(p, reduce);

        -- 最小一点
        reduce = math.max(1, reduce);

        return base - math.modf(base * reduce / 1000);
    end,

    clear = function(who, prop)
        if OBJECT_TYPE_USER == who.type then
            EventMgr.fire(event.USER_INFO_UPDATED, "attack");
        end
    end,

    record = function(target, prop, path)
        return false;
    end
};
